import { CpcBase, ICpcBaseIos } from "../base/CpcBase";
import { LitegraphUtils } from "../../utils/LitegraphUtils";

const ios: ICpcBaseIos = {
    inputs: [
        {
            name: "输入的数据",
            type: 0,
        },
    ],
    outputs: [],
};

export class CpcAlert extends CpcBase {
    public title = "Alert";

    public desc = "Alert";

    public type = "CpcAlert";

    public properties = {
        type: "String",
    };

    constructor(title?: string) {
        super(ios, title);
    }

    cpcRunCode(preDatas: any[], inputInfos: any[], outputInfos: any[]): any[] {
        const data = preDatas[0];
        const type = LitegraphUtils.checkType(data);
        if (type === "Object" || type === "Array") {
            alert(JSON.stringify(data));
        } else {
            alert(data);
        }
        return [];
    }
}
